<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://www.ecside.org" prefix="ec"%>
<jsp:useBean id="pageBean" scope="request" class="com.agileai.hotweb.domain.PageBean"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>流程定义管理</title>
<%@include file="/jsp/inc/resource.inc.jsp"%>
<script language="javascript">
function controlButton(trObj,params,state,name){
	selectRow(trObj,params);
	var innerHtml = $('#publishTd').html();
	if (state == 'released'){
		$('#publishTd').html(innerHtml.replace('发布','撤销'));
		disableButton('delImgBtn');		
		enableButton('upgradeImgBtn');
		enableButton('reloadImgBtn');
	}else{
		$('#publishTd').html(innerHtml.replace('撤销','发布'));
		enableButton('delImgBtn');
		disableButton('upgradeImgBtn');
		disableButton('reloadImgBtn');
	}
	$('#CUR_WFP_STATE').val(state);
	$('#WFP_NAME').val(name);
}
function publishCancel(){
	var curState = $('#CUR_WFP_STATE').val();
	postRequest('form1',{actionType:'publishCancel',onComplete:function(rspText){
		if ("success" == rspText){
			if (curState == 'released'){
				alert('撤销操作成功！');
			}else{
				alert('发布操作成功！');
			}						
			doQuery();
		}else{
			if (curState == 'released'){
				alert('撤销操作失败！');
			}else{
				alert('发布操作失败！');
			}
		}
	}});
}
function reloadProcess(){
	if(!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;
	}
	postRequest('form1',{actionType:'reloadProcess',onComplete:function(rspText){
		if ("success" == rspText){
			alert('重新加载成功！');
		}else{
			alert('重启加载失败！');
		}
	}});	
}
function upgradeProcess(){
	if(!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;
	}
	if (confirm('你确认要生成新的版本？')){
		postRequest('form1',{actionType:'upgrade',onComplete:function(rspText){
			if (confirm('升级流程成功,马上编辑流程吗？')){
				ele('WFP_ID').value=rspText;
				doRequest('designRequest');
			}else{
				doQuery();
			}
		}});		
	}
}
var processXmlBox;
function viewProcessXmlRequest(){
	if(!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;
	}	
	if (!processXmlBox){
		processXmlBox = new PopupBox('processXmlBox','流程定义信息',{size:'big',height:'530px',width:'900px'});		
	}
	processXmlBox.sendRequest('index?WfProcessDefineXML&actionType=prepareDisplay&WFP_ID='+$('#WFP_ID').val());
}
function checkExist(){
	postRequest('form1',{actionType:'checkExist',onComplete:function(rspText){
		if (rspText == 'ExistEmulation'){
			if (confirm('存在仿真实例，不能删除流程定义。你想要立刻操作仿真实例吗？')){
				doSubmit({actionType:'viewEmulation'});
			}
		}else if (rspText == 'ExistInstance'){
			alert('已存在流程实例或者历史记录，不能删除流程定义！');
		}else{
			doDelete($('#'+rsIdTagId).val());
		}
	}});	
}
var generalBox;
function setupRequest(){
	if(!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;
	}
	if (!generalBox){
		generalBox = new PopupBox('generalBox','流程基础信息',{top:'30px',size:'big',height:'530px'});		
	}
	generalBox.sendRequest('index?WfProcessGeneralEdit&WFP_ID='+$('#WFP_ID').val());
}
</script>
</head>
<body>
<form action="<%=pageBean.getHandlerURL()%>" name="form1" id="form1" method="post">
<%@include file="/jsp/inc/message.inc.jsp"%>
<div id="__ParamBar__" style="float: right;">
流程分组<select name="WFP_GROUP" id="WFP_GROUP" onChange="doQuery()"><%=pageBean.selectValue("WFP_GROUP")%></select>&nbsp;&nbsp;流程状态
<select name="WFP_STATE" id="WFP_STATE" onChange="doQuery()"><%=pageBean.selectValue("WFP_STATE")%></select>
<input type="button" name="button" id="button" value="查询" class="formbutton" onclick="doQuery()" />
</div>
<div id="__ToolBar__">
<table border="0" cellpadding="0" cellspacing="1">
<tr>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="A" class="bartdx" align="center" onClick="doRequest('insertRequest')"><input value="&nbsp;" title="新增" type="button" class="createImgBtn" />新增</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="E" class="bartdx" align="center" onClick="setupRequest()"><input value="&nbsp;" title="编辑" type="button" class="editImgBtn" />编辑</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onClick="viewProcessXmlRequest()"><input value="&nbsp;" type="button" class="viewImgBtn" title="定义" />定义</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onClick="doRequest('viewInstance')"><input value="&nbsp;" type="button" class="detailImgBtn" title="实例" />实例</td>         
   <td id="publishTd" onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onClick="publishCancel()"><input value="&nbsp;" type="button" class="relateImgBtn" />发布</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onClick="reloadProcess()"><input id="reloadImgBtn" value="&nbsp;" type="button" class="reloadImgBtn" title="重新加载" />重新加载</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="F" class="bartdx" align="center" onClick="doRequest('designRequest')"><input value="&nbsp;" title="设计" type="button" class="designImgBtn" />设计</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onClick="upgradeProcess()"><input value="&nbsp;" title="升级" type="button" id="upgradeImgBtn" class="upgradeImgBtn" />升级</td>   
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="D" class="bartdx" align="center" onClick="checkExist()"><input value="&nbsp;" title="删除" type="button" id="delImgBtn" class="delImgBtn" />删除</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="B" class="bartdx" align="center" onClick="goToMain();"><input value="&nbsp;" title="返回" type="button" class="backImgBtn" />返回</td>   
</tr>
</table>
</div>
<ec:table 
form="form1"
var="row"
items="pageBean.rsList" csvFileName="流程定义管理.csv"
retrieveRowsCallback="process" xlsFileName="流程定义管理.xls"
useAjax="true" sortable="true"
doPreload="false" toolbarContent="navigation|pagejump |pagesize |export|extend|status"
width="100%" rowsDisplayed="10"
listWidth="100%" 
height="400px" 
excludeParameters="actionType"
>
<ec:row styleClass="odd" ondblclick="doRequest('designRequest')" oncontextmenu="controlButton(this,{WFP_ID:'${row.WFP_ID}'},'${row.WFP_STATE}','${row.WFP_NAME}');refreshConextmenu()" onclick="controlButton(this,{WFP_ID:'${row.WFP_ID}'},'${row.WFP_STATE}','${row.WFP_NAME}')">
	<ec:column width="50" style="text-align:center" property="_0" title="序号" value="${GLOBALROWCOUNT}" />
	<ec:column width="100" property="WFP_CODE" title="编码"   />
	<ec:column width="80" property="WFP_VERSION" title="版本"   />    
	<ec:column width="250" property="WFP_NAME" title="名称"   />
	<ec:column width="80" property="WFP_STATE" mappingItem="WFP_STATE" title="状态"   />
	<ec:column width="80" property="WFP_GROUP" mappingItem="WFP_GROUP" title="所属分组"   />
</ec:row>
</ec:table>
<input type="hidden" name="WFP_ID" id="WFP_ID" value="" />
<input type="hidden" name="WFP_NAME" id="WFP_NAME" value="" />
<input type="hidden" name="WFP_CODE" id="WFP_CODE" value="" />
<input type="hidden" name="CUR_WFP_STATE" id="CUR_WFP_STATE" value="" />
<input type="hidden" name="actionType" id="actionType" />
<script language="JavaScript">
setRsIdTag('WFP_ID');
var ectableMenu = new EctableMenu('contextMenu','ec_table');
</script>
</form>
</body>
</html>
<%@include file="/jsp/inc/scripts.inc.jsp"%>
